import React from 'react'
import { Panel, Tab, NavBar, NavBarItem, TabBody} from 'react-weui'
import { browserHistory } from 'react-router'

export default class OrderInfo extends React.Component {
	constructor(props) {
		super(props)
		this.state = {
			tab: 0
		}
    }
    componentDidMount(){
    	const pathName = this.props.pathName;
    	const storeId = this.props.storeId;
    	switch(pathName) {
    		case `/store/${storeId}/user/order`: this.setState({tab:0});break;
    		case `/store/${storeId}/user/order/will-pay`: this.setState({tab:1});break;
    		case `/store/${storeId}/user/order/will-send`: this.setState({tab:2});break;
    		case `/store/${storeId}/user/order/will-receive`: this.setState({tab:3});break;
    		case `/store/${storeId}/user/order/will-comment`: this.setState({tab:4});break;
    	}
    }
	render() {
		const { storeId } = this.props;
		return (
	        <NavBar style={{ position: 'fixed', top: '55px'}}>
		        <NavBarItem active={this.state.tab == 0} onClick={e=>{browserHistory.push(`/store/${storeId}/user/order`);this.setState({tab:0})}}>全部</NavBarItem>
		        <NavBarItem active={this.state.tab == 1} onClick={e=>{browserHistory.push(`/store/${storeId}/user/order/will-pay`);this.setState({tab:1})}}>待付款</NavBarItem>
		        <NavBarItem active={this.state.tab == 2} onClick={e=>{browserHistory.push(`/store/${storeId}/user/order/will-send`);this.setState({tab:2})}}>待发货</NavBarItem>
		        <NavBarItem active={this.state.tab == 3} onClick={e=>{browserHistory.push(`/store/${storeId}/user/order/will-receive`);this.setState({tab:3})}}>待收货</NavBarItem>
		        <NavBarItem active={this.state.tab == 4} onClick={e=>{browserHistory.push(`/store/${storeId}/user/order/will-comment`);this.setState({tab:4})}}>待评价</NavBarItem>
		    </NavBar>
		);
	}
}
